<template>
	<view class="main">
		<u-navbar :is-back="false" title="待处理" :background="background" back-icon-color="#000000" title-color="#33312D"
			title-bold="true"></u-navbar>


		<view class="mine_take">
			<view class="alls" v-for="(item,index) in list " :key="index">
				<view class="top">
					<text class="time">付款时间:{{formatTime(item.pay_time,'YYYY-MM-DD hh:mm:ss')}}</text>
				</view>
				<view class="content" @click="router('order_processed/order_processed',item)">
					<view class="id">
						订单编号:{{item.orderno}}
					</view>
					<view class="shop_details" v-for="(shop,id) in item.good_info" :key="id">
						<view class="left">
							<image :src="item.image" mode=""></image>
							<view class="shop_tit">
								{{shop.name}}
								<text>{{shop.specs}}</text>
							</view>
						</view>
						<view class="right">
							<view>
								¥{{shop.price}}
							</view>
							<text>x{{shop.amount}}</text>
						</view>
					</view>
				</view>
				<view class="money">
					实付: ¥{{item.pay_true}}
				</view>
				<view class="button2">
					<view class="left" @click="confirm(item.id,0)">
						取消订单
					</view>
					<view class="right" @click="confirm(item.id,1)">
						确认接单
					</view>
				</view>
			</view>
		</view>
<!-- 		<view class="button" @click="router">
			打印
		</view> -->



	</view>
</template>
<script>
	export default {
		data() {
			return {
				background: {
					backgroundColor: '#fff'
				},
				tab: ['预订订单', '自取订单', '进行订单', '完成订单', '退款订单'],
				ex: 3,
				list: []
			}
		},
		
		onLoad() {
			if(uni.getStorageSync('token')==''){
				uni.showToast({
					title: '请先登录',
					icon: "none",
					mask: true,
					duration: 700
				})
				setTimeout(function() {
					console.log(222);
					uni.navigateTo({
						url: '../logins/login/login'
					})
				}, 700)
			}
			this.getlist()

		},
		mounted() {

		},
		onShow() {},
		methods: {
			confirm(id,status){
				global.$http.request({
					url:'/shopapi/order/orderStatus',
					data:{
						token:uni.getStorageSync('token'),
						id:id,
						status:status
					}
				}).then(res=>{
					if(res.data.code==200){
						uni.showToast({
							title:res.data.msg,
							icon:'none',
							duration:700
						})
						var that =this
						setTimeout(function() {
						that.getlist()
						}, 700)
					}
				})
			},
			getlist() {
				global.$http.request({
					url: '/shopapi/order/orderList',
					data: {
						token: uni.getStorageSync('token'),
						type: 5
					}
				}).then(res => {
					if (res.data.code == 200) {
						console.log(res.data.data);
						this.list = res.data.data
					}
				})
			},
			//跳转页面
			router(path, details) {
				uni.navigateTo({
					url: path + '?details=' + encodeURIComponent(JSON.stringify(details)) + '&status=' + this
						.takestat,
				})
			},
			tabeds(e) {
				console.log(e);
				this.ex = e
			}

		}
	}
</script>
<style lang="scss">
	page {
		font-family: Source Han Sans CN;
		width: 750rpx;
		margin: 0 auto;
		background-color: #f7f7f7;
		padding-bottom: 100rpx;

		.main {

			width: 750rpx;
			margin: 0 auto;

			.mine_take {


				width: 750rpx;


				.alls {
					width: 750rpx;
					padding: 24rpx 23rpx 18rpx 23rpx;
					background-color: #fff;
					margin-bottom: 4rpx;

					.top {
						padding-bottom: 21rpx;

						text {
							font-size: 26rpx;
							font-weight: 400;
							color: #FF0000;
						}

						.time {
							font-size: 24rpx;
							font-weight: 400;
							color: #4D4D4D;
						}
					}

					.content {
						padding: 16rpx;
						background: #F8F8F8;

						.id {
							font-size: 20rpx;
							font-weight: 400;
							color: #4D4D4D;
						}

						.shop_details {
							padding-top: 20rpx;
							display: flex;
							justify-content: space-between;

							image {
								width: 114rpx;
								height: 114rpx;
							}

							.left {
								display: flex;

								.shop_tit {
									width: 420rpx;
									padding-left: 8rpx;
									font-size: 24rpx;
									font-weight: 400;
									color: #000000;
									line-height: 30rpx;

									text {
										display: block;
										font-size: 20rpx;
										font-weight: 400;
										color: #4D4D4D;
										padding-top: 16rpx;
									}
								}

							}

							.right {
								text-align: right;

								view {
									font-size: 24rpx;
									font-weight: 400;
									color: #000000;
									line-height: 27rpx;
								}

								text {
									font-size: 20rpx;
									font-weight: 400;
									color: #4D4D4D;
								}
							}
						}
					}

					.money {
						font-size: 30rpx;
						font-weight: 400;
						color: #000000;
						padding: 30rpx 0;
						text-align: right;
					}

					.button2 {
						text-align: center;
						display: flex;
						justify-content: space-around;
						align-items: center;

						.left {
							width: 340rpx;
							background: #808080;
							padding: 19rpx 0;
							border-radius: 62rpx;
							font-size: 26rpx;
							font-weight: 400;
							color: #FFFFFF;
						}

						.right {
							width: 340rpx;
							background: #E22222;
							padding: 19rpx 0;
							border-radius: 62rpx;
							font-size: 26rpx;
							font-weight: 400;
							color: #FFFFFF;
						}
					}

				}

			}

			.button {
				position: fixed;
				bottom: 0;
				font-size: 32rpx;
				font-weight: bold;
				color: #FFFFFF;
				text-align: center;
				padding: 34rpx 0;
				width: 750rpx;
				background: #E13C3D;
			}
		}
	}
</style>
